<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客服管理</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<link rel="stylesheet" href="<%=basePath%>plugins/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />

<style type="text/css">
	.kflxtcdiv {display:none;}
	
</style>

</head>
<body>

<div class="admin-tab admin-user admin-transform">
    <div class="tab-condition">
        <form class="layui-form clefix" action="/customer/servicemanageurl" method="post" id="transformform">
            <div class="layui-form-item">
            	<div class="layui-input-inline">
	                  	<input type="text" name="keyWord" id="keyWord" class="layui-input" placeholder="请输入关键字"  style="width:100%" value="${pager.params.keyWord}"> 
	            </div>
                <div class="layui-input-inline">
                    <select name="type" id="type" lay-filter="type" class="typeclass">
                        <option value="">请选择客户类型</option>
                        <option value="-1" <c:if test="${pager.params.type == -1}">selected</c:if>>全部</option>
                        <option value="1" <c:if test="${pager.params.type == 1}">selected</c:if>>企业</option>
                        <option value="0" <c:if test="${pager.params.type == 0}">selected</c:if>>个人</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="servicesign" id="servicesign" lay-filter="servicesign" class="typeclass">
                        <option value="">请选择标记</option>
                        <option value="-2" <c:if test="${pager.params.servicesign == -2}">selected</c:if>>全部</option>
                        <option value="0" <c:if test="${pager.params.servicesign == 0}">selected</c:if>>空号</option>
                        <option value="1" <c:if test="${pager.params.servicesign == 1}">selected</c:if>>已联系</option>
                        <option value="2" <c:if test="${pager.params.servicesign == 2}">selected</c:if>>未联系</option>
                        <option value="3" <c:if test="${pager.params.servicesign == 3}">selected</c:if>>无人接听</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
            	<input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}">
				<input type="hidden" id="pageNo" name="pageNo" value="${pager.pageNo}">
				<input type="hidden" id="totalPage" name="totalPage" value="${pager.totalPages}">
				<input type="hidden" id="pageSize" name="pageSize" value="${pager.pageSize}">
                <button class="layui-btn search" type="button" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i>搜索</button>
            </div>
        </form>
        <div class="TM-tab-info">
            <a class="layui-btn layui-btn-primary layui-btn-small refreshbtn"><i class="layui-icon">&#x1002;</i>刷新</a>
        </div>
    </div>
    <div class="layui-field-box">
        <table class="site-table table-hover TM-user TM-table3">
            <thead>
            <tr>
                <th style="width:10%">客户名称</th>
                <th style="width:10%">类别</th>
                <th style="width:10%">所属人</th>
                <th style="width:10%">合同</th>
                <th style="width:10%;">标记</th>
                <th style="width:10%;">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="obj" items="${pager.resultList}" varStatus="o1">
            	<tr data="${obj.id}">
            		<td>${obj.cname}</td>
            		<td>${obj.type==0?'个人':'企业'}</td>
            		<td>${obj.createusersname}</td>
            		<td >${obj.contractcount > 0 ? '已签合同' : '未签合同'}</td>
            		<td >
            			<c:if test="${obj.servicesign == null ||  obj.servicesign == 2}">未联系</c:if>
            			<c:if test="${obj.servicesign == 1}">已联系</c:if>
            			<c:if test="${obj.servicesign == 0}">空号</c:if>
            			<c:if test="${obj.servicesign == 3}">无人接听</c:if>
            		</td>
            		<td>
            			<a href="/customer/findcustomer${obj.id}" target="_blank" class="layui-btn layui-btn-normal layui-btn-mini showinfo" data="${obj.id}">查看</a>
            			<a href="#" class="layui-btn layui-btn-normal layui-btn-mini markinfo" data="${obj.id}">标记</a>
            		</td>
            	</tr>
            </c:forEach>
            </tbody>
        </table>
        <div class="admin-table-page">
            <div id="page" class="page"></div>
        </div>
    </div>
</div>

<!-- 客服联系弹窗 -->
<div class="kflxtcdiv">
	<div style="margin-top: 10px;">
		<form action="" id="kflx_form"  class="layui-form" >
			<div class="layui-form-item">
				<label class="layui-form-label"><span>标记 : </span></label>
				<div class="layui-input-inline">
					<select name="state" id="state" lay-filter="lay-filter">
						<option>请选择标记</option>
						<option value="0">空号</option>
						<option value="1">已联系</option>
						<option value="2">未联系</option>
						<option value="3">无人接听</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span>备注 : </span></label>
				<div class="layui-input-inline">
					<textarea placeholder="请输入内容" class="layui-textarea" id="remark" name="remark"></textarea>
				</div>
			</div>
			<input type="hidden"  id="lxid" name="id" value="">
		</form>
	</div>
	
</div>


<script type="text/javascript">

layui.config({
    base: 'plugins/layui/modules/'
});

layui.use(['element','laypage','form','laydate','layer'], function() {
	
	var $ = layui.jquery,
    laypage = layui.laypage,
    layer = layui.layer,
    element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
	var form = layui.form();
    
	var pageNo = $("#pageNo").val();
	var totalPage = $("#totalPage").val();
	var tjstate =0;
	
	
     
	//page
    laypage({
        cont: 'page',
        curr: pageNo//'${pager.pageNo}'
        ,pages: totalPage//'${pager.totalPages}' //总页数
        ,
        groups: 5 //连续显示分页数
        ,
        jump: function(obj, first) {
            //得到了当前页，用于向服务端请求对应数据
            var curr = obj.curr;
            if(!first) {
            	$("#skipToPage").val(curr);
            	$("#transformform").submit();
            }
        }
    });
	

	  
  /* 	$("#transformform").validate({
  		rules : {},
  		messages : {},
  		errorPlacement : function(error, element) {
  			layer.tips(error.text(), element, {
					tips: [2,tipColor],
	     		 tipsMore: true
	     		});
  		},
  		submitHandler : function(form) {
  			alert(1);
  			$("#transformform").submit();
  		}
  	}); */
  	
  	$(".search").on("click",function(){
  		$("#skipToPage").val(1);
  		$("#transformform").submit();
  	});
  	
  	/* 添加标记 */
	$(".markinfo").on("click",function(){
		//清空输入框内容
		$("#lxid").val('');
		$("#state").val('');
		$("#remark").text('');
		form.render();
		//标记只有一个 点击后ajax先从后台查,然后有的话带过来,修改,没有就直接新增
		var cusid = $(this).attr("data");
		//获取当前日期时间
		var myDate = new Date();    
 		var dateTime = myDate.toLocaleDateString();
		$.ajax({
			type : "post",
			data : {cusid : cusid},
			url : "/customer/checkservicesign",
			dataType : "json",
			success : function(data){
				if (data != null) {
					//将获取的内容存到弹窗中
					$("#lxid").val(data["id"]);
					$("#state").val(data["state"]);
					$("#remark").text(data["remark"]+dateTime+":");
					form.render();
				} else {
					$("#remark").text(dateTime+":");
				}
				//打开弹窗
				layer.open({
					type:1,
					btn:['确定','取消'],
					btnAlign:'c',
					shadeClose:true,
					title:"标记",
					zIndex: 999,
					content: $(".kflxtcdiv"),
					area:['30%','50%'],
					yes: function(layero, index){
						var state = $("#state").val();
						var remark = $("#remark").val();
						var id = $("#lxid").val();
						$.ajax({
							type : "post",
							data : {cusid:cusid,state:state,remark:remark,id:id},
							url : "/customer/saveservicesign",
							dataType:"json",
							success:function(data){
								layer.msg("标记成功",function(){
									window.location.reload();
								});
							}
						})
					}
				});
			}
		});
	});
});
	
</script>



</body>
</html>